﻿<html>

<head>
<meta http-equiv=Content-Type content="text/html; charset=UTF-8">
<meta name=Generator content="Microsoft Word 14 (filtered)">
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:Wingdings;
	panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:宋体;
	panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
	{font-family:Tahoma;
	panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
	{font-family:"\@宋体";
	panose-1:2 1 6 0 3 1 1 1 1 1;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	font-size:10.5pt;
	font-family:"Times New Roman","serif";}
h1
	{mso-style-link:"标题 1 Char";
	margin-right:0cm;
	margin-left:0cm;
	font-size:24.0pt;
	font-family:宋体;}
h3
	{mso-style-link:"标题 3 Char";
	margin-top:13.0pt;
	margin-right:0cm;
	margin-bottom:13.0pt;
	margin-left:0cm;
	text-align:justify;
	text-justify:inter-ideograph;
	line-height:173%;
	page-break-after:avoid;
	font-size:16.0pt;
	font-family:"Times New Roman","serif";}
p.MsoHeader, li.MsoHeader, div.MsoHeader
	{margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	layout-grid-mode:char;
	border:none;
	padding:0cm;
	font-size:9.0pt;
	font-family:"Times New Roman","serif";}
p.MsoFooter, li.MsoFooter, div.MsoFooter
	{margin:0cm;
	margin-bottom:.0001pt;
	layout-grid-mode:char;
	font-size:9.0pt;
	font-family:"Times New Roman","serif";}
span.1Char
	{mso-style-name:"标题 1 Char";
	mso-style-link:"标题 1";
	font-family:宋体;
	font-weight:bold;}
span.3Char
	{mso-style-name:"标题 3 Char";
	mso-style-link:"标题 3";
	font-weight:bold;}
 /* Page Definitions */
 @page WordSection1
	{size:595.3pt 841.9pt;
	margin:72.0pt 90.0pt 72.0pt 90.0pt;
	layout-grid:15.6pt;}
div.WordSection1
	{page:WordSection1;}
 /* List Definitions */
 ol
	{margin-bottom:0cm;}
ul
	{margin-bottom:0cm;}
-->
</style>

</head>

<body bgcolor=white lang=ZH-CN style='text-justify-trim:punctuation'>

<div class=WordSection1 style='layout-grid:15.6pt'>

<h1 align=center style='text-align:center'>数据类型、运算符</h1>

<p class=MsoNormal align=left style='text-align:left;line-height:16.5pt'><span
style='font-family:宋体;color:#555555'>在第一章中，我们已经看到程序中使用的各种变量都应预先加以定义，即先定义，后使用。对变量的定义可以包括三个方面：</span><span
style='font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>数据类型、存储类型、作用域。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555'>在本章中，我们只介绍数据类型的说明。其它说明在以后各章中陆续介绍。所谓数据类型是按被定义变量的性质，表示形式，占据存储空间的多少，构造特点来划分的。在Ｃ语言中，数据类型可分为：</span><span
style='font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>基本数据类型，构造数据类型，指针类型，空类型四大类</span><span
style='font-family:宋体;color:#555555'>。</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<img width=273 height=590 src="3.files/image001.jpg" alt=C语言数据类型><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>1.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>基本数据类型：基本数据类型最主要的特点是，其值不可以再分解为其它类型。也就是说，基本数据类型是自我说明的。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>2.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>构造数据类型：构造数据类型是根据已定义的一个或多个数据类型用构造的方法来定义的。也就是说，一个构造类型的值可以分解成若干个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>“</span><span
style='font-family:宋体;color:#555555'>成员</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>”</span><span
style='font-family:宋体;color:#555555'>或</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>“</span><span style='font-family:宋体;
color:#555555'>元素</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>”</span><span style='font-family:宋体;color:#555555'>。每个</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>“</span><span
style='font-family:宋体;color:#555555'>成员</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>”</span><span
style='font-family:宋体;color:#555555'>都是一个基本数据类型或又是一个构造类型。在</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>C</span><span
style='font-family:宋体;color:#555555'>语言中，构造类型有以下几种：</span><span
style='font-family:宋体;color:green;border:none windowtext 1.0pt;padding:0cm'>数组类型、结构体类型、共用体（联合）类型</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>3.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>指针类型：指针是一种特殊的，同时又是具有重要作用的数据类型。其值用来表示某个变量在内存储器中的地址。虽然指针变量的取值类似于整型量，但这是两个类型完全不同的量，因此不能混为一谈。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt'><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>4.<span style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>空类型：在调用函数值时，通常应向调用者返回一个函数值。这个返回的函数值是具有一定的数据类型的，应在函数定义及函数说明中给以说明，例如在例题中给出的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>max</span><span
style='font-family:宋体;color:#555555'>函数定义中，函数头为：</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>int max(int a,int b);</span><span
style='font-family:宋体;color:#555555'>其中</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>“int ”</span><span
style='font-family:宋体;color:#555555'>类型说明符即表示该函数的返回值为整型量。又如在例题中，使用了库函数</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>sin</span><span
style='font-family:宋体;color:#555555'>，由于系统规定其函数返回值为双精度浮点型，因此在赋值语句</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>s=sin (x);</span><span
style='font-family:宋体;color:#555555'>中，</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>s </span><span
style='font-family:宋体;color:#555555'>也必须是双精度浮点型，以便与</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>sin</span><span
style='font-family:宋体;color:#555555'>函数的返回值一致。所以在说明部分，把</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>s</span><span
style='font-family:宋体;color:#555555'>说明为双精度浮点型。但是，也有一类函数，调用后并不需要向调用者返回函数值，这种函数可以定义为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>“</span><span
style='font-family:宋体;color:#555555'>空类型</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>”</span><span
style='font-family:宋体;color:#555555'>。其类型说明符为</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>void</span><span
style='font-family:宋体;color:#555555'>。在后面函数中还要详细介绍。</span></p>

<p class=MsoNormal align=left style='text-align:left;line-height:16.5pt'><span
style='font-family:宋体;color:#555555'>在本章中，我们先介绍基本数据类型中的整型、浮点型和字符型。其余类型在以后各章中陆续介绍。</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>对于基本数据类型量，按其取值是否可改变又分为常量和变量两种。在程序执行过程中，其值不发生改变的量称为常量，其值可变的量称为变量。它们可与数据类型结合起来分类。例如，可分为整型常量、整型变量、浮点常量、浮点变量、字符常量、字符变量、枚举常量、枚举变量。在程序中，常量是可以不经说明而直接引用的，而变量则必须先定义后使用。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>整型量包括整型常量、整型变量。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.1</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>常量和符号常量</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>在程序执行过程中，其值不发生改变的量称为常量。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>直接常量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>(</span><span
style='font-family:宋体;color:#555555'>字面常量</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>)</span><span
style='font-family:宋体;color:#555555'>：</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>整型常量：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>12</span><span
style='font-family:宋体;color:#555555'>、</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>0</span><span style='font-family:宋体;
color:#555555'>、</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>-3</span><span style='font-family:宋体;color:#555555'>；</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>实型常量：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>4.6</span><span
style='font-family:宋体;color:#555555'>、</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>-1.23</span><span style='font-family:宋体;
color:#555555'>；</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>字符常量：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>‘a’</span><span
style='font-family:宋体;color:#555555'>、</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>‘b’</span><span style='font-family:宋体;
color:#555555'>。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>标识符：用来标识变量名、符号常量名、函数名、数组名、类型名、文件名的有效字符序列。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>符号常量：用标示符代表一个常量。在Ｃ语言中，可以用一个标识符来表示一个常量，称之为符号常量。</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>符号常量在使用之前必须先定义，其一般形式为：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>#define </span><span style='font-family:宋体;color:#555555;background:
white'>标识符</span><span style='font-family:"Tahoma","sans-serif";color:#555555;
background:white'> </span><span style='font-family:宋体;color:#555555;background:
white'>常量</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>其中</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>#define</span><span style='font-family:宋体;color:#555555;background:white'>也是一条预处理命令（预处理命令都以</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&quot;#&quot;</span><span style='font-family:宋体;color:#555555;
background:white'>开头），称为宏定义命令（在后面预处理程序中将进一步介绍），其功能是把该标识符定义为其后的常量值。一经定义，以后在程序中所有出现该标识符的地方均代之以该常量值。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>习惯上符号常量的标识符用大写字母，变量标识符用小写字母，以示区别。</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.1</span><span style='font-family:宋体;color:#555555;background:white'>】符号常量的使用。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>#define PRICE 30</span><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>&nbsp; int num,total;</span><br>
<span style='background:white'>num=10;</span><br>
<span style='background:white'>total=num* PRICE;</span><br>
<span style='background:white'>printf(“total=%d”,total);</span><br>
<span style='background:white'>}</span><br>
<br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>用标识符代表一个常量，称为符号常量。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>符号常量与变量不同，它的值在其作用域内不能改变，也不能再被赋值。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>使用符号常量的好处是：</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:#555555'>o<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>含义清楚；</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:"Courier New";color:#555555'>o<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>能做到</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>“</span><span
style='font-family:宋体;color:#555555'>一改全改</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>”</span><span
style='font-family:宋体;color:#555555'>。</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.2</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>变量</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>其值可以改变的量称为变量。一个变量应该有一个名字，在内存中占据一定的存储单元。变量定义必须放在变量使用之前。一般放在函数体的开头部分。要区分变量名和变量值是两个不同的概念。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span lang=EN-US><img width=233 height=151 src="3.files/image002.jpg"
alt=C语言变量></span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.1</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>整型常量的表示方法</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>整型常量就是整常数。在Ｃ语言中，使用的整常数有八进制、十六进制和十进制三种。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>十进制整常数：十进制整常数没有前缀。其数码为</span></strong><strong><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>～</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>9</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>。</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>以下各数是合法的十进制整常数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>237</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>-568</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>65535</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>1627</span><span style='font-family:宋体;color:#555555;background:white'>；</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>以下各数不是合法的十进制整常数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>023 (</span><span style='font-family:宋体;color:#555555;background:white'>不能有前导</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>23D (</span><span style='font-family:宋体;color:#555555;background:white'>含有非十进制数码</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span style='font-family:宋体;color:#555555;background:white'>。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>在程序中是根据前缀来区分各种进制数的。因此在书写常数时不要把前缀弄错造成结果不正确。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>八进制整常数：八进制整常数必须以</span></strong><strong><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>开头，即以</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>作为八进制数的前缀。数码取值为</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>～</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>7</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>。八进制数通常是无符号数。</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>以下各数是合法的八进制数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>015(</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>13)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0101(</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>65)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0177777(</span><span style='font-family:宋体;color:#555555;background:
white'>十进制为</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>65535)</span><span style='font-family:宋体;
color:#555555;background:white'>；</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>以下各数不是合法的八进制数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>256(</span><span style='font-family:宋体;color:#555555;background:white'>无前缀</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>03A2(</span><span style='font-family:宋体;color:#555555;background:white'>包含了非八进制数码</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>-0127(</span><span style='font-family:宋体;color:#555555;background:white'>出现了负号</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span style='font-family:宋体;color:#555555;background:white'>。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>十六进制整常数：十六进制整常数的前缀为</span></strong><strong><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0X</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>或</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0x</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>。其数码取值为</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0~9</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>，</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>A~F</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>或</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>a~f</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>。</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>以下各数是合法的十六进制整常数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0X2A(</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>42)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0XA0 (</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>160)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0XFFFF (</span><span style='font-family:宋体;color:#555555;background:
white'>十进制为</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>65535)</span><span style='font-family:宋体;
color:#555555;background:white'>；</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>以下各数不是合法的十六进制整常数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>5A (</span><span style='font-family:宋体;color:#555555;background:white'>无前缀</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0X)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0X3H (</span><span style='font-family:宋体;color:#555555;background:white'>含有非十六进制数码</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span style='font-family:宋体;color:#555555;background:white'>。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>4.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>整型常数的后缀：在</span></strong><strong><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>16</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>位字长的机器上，基本整型的长度也为</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>16</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>位，因此表示的数的范围也是有限定的。十进制无符号整常数的范围为</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>～</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>65535</span></strong><strong><span style='font-family:宋体;
color:green;border:none windowtext 1.0pt;padding:0cm'>，有符号数为</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>-32768</span></strong><strong><span style='font-family:宋体;
color:green;border:none windowtext 1.0pt;padding:0cm'>～</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>+32767</span></strong><strong><span style='font-family:宋体;
color:green;border:none windowtext 1.0pt;padding:0cm'>。八进制无符号数的表示范围为</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>～</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0177777</span></strong><strong><span style='font-family:宋体;
color:green;border:none windowtext 1.0pt;padding:0cm'>。十六进制无符号数的表示范围为</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0X0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>～</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0XFFFF</span></strong><strong><span style='font-family:宋体;
color:green;border:none windowtext 1.0pt;padding:0cm'>或</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0x0</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>～</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0xFFFF</span></strong><strong><span style='font-family:宋体;
color:green;border:none windowtext 1.0pt;padding:0cm'>。如果使用的数超过了上述范围，就必须用长整型数来表示。长整型数是用后缀</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>“L”</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>或</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>“l”</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>来表示的。</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>十进制长整常数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>158L (</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>158)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>358000L (</span><span style='font-family:宋体;color:#555555;background:
white'>十进制为</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>358000)</span><span style='font-family:宋体;
color:#555555;background:white'>；</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>八进制长整常数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>012L (</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>10)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>077L (</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>63)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0200000L (</span><span style='font-family:宋体;color:#555555;background:
white'>十进制为</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>65536)</span><span style='font-family:宋体;
color:#555555;background:white'>；</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>十六进制长整常数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0X15L (</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>21)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0XA5L (</span><span style='font-family:宋体;color:#555555;background:white'>十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>165)</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0X10000L (</span><span style='font-family:宋体;color:#555555;background:
white'>十进制为</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>65536)</span><span style='font-family:宋体;
color:#555555;background:white'>。</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>长整数</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>158L</span><span style='font-family:宋体;color:#555555;background:white'>和基本整常数</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>158 </span><span style='font-family:宋体;color:#555555;background:white'>在数值上并无区别。但对</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>158L</span><span style='font-family:宋体;color:#555555;background:white'>，因为是长整型量，Ｃ编译系统将为它分配</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>4</span><span style='font-family:宋体;color:#555555;background:white'>个字节存储空间。而对</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>158</span><span style='font-family:宋体;color:#555555;background:white'>，因为是基本整型，只分配</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>2 </span><span style='font-family:宋体;color:#555555;background:white'>个字节的存储空间。因此在运算和输出格式上要予以注意，避免出错。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>无符号数也可用后缀表示，整型常数的无符号数的后缀为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>“U”</span><span style='font-family:宋体;color:#555555;background:white'>或</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>“u”</span><span style='font-family:宋体;color:#555555;background:white'>。例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>358u,0x38Au,235Lu</span><span style='font-family:宋体;color:#555555;
background:white'>均为无符号数。</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>前缀，后缀可同时使用以表示各种类型的数。如</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0XA5Lu</span><span style='font-family:宋体;color:#555555;background:white'>表示十六进制无符号长整数</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>A5</span><span style='font-family:宋体;color:#555555;background:white'>，其十进制为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>165</span><span style='font-family:宋体;color:#555555;background:white'>。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.2</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>整型变量</span></h3>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>整型数据在内存中的存放形式</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>如果定义了一个整型变量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>i</span><span style='font-family:宋体;color:#555555;background:white'>：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>int i;</span><br>
<span style='background:white'>i=10;</span><br>
<span style='background:white'>i&nbsp; 10</span><br>
</span><span lang=EN-US><img width=355 height=32 src="3.files/image003.jpg"
alt=整型变量></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>数值是以补码表示的：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>正数的补码和原码相同；</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>负数的补码：将该数的绝对值的二进制形式按位取反再加</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>1</span><span
style='font-family:宋体;color:#555555'>。</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>例如：求</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>-10</span><span style='font-family:宋体;color:#555555;background:white'>的补码：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span lang=EN-US><img width=403 height=130 src="3.files/image004.jpg"></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>由此可知，左面的第一位是表示符号的。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>整型变量的分类</span></strong></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>基本型：类型说明符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>int</span><span
style='font-family:宋体;color:#555555'>，在内存中占</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2</span><span
style='font-family:宋体;color:#555555'>个字节。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>短整量：类型说明符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>short int</span><span
style='font-family:宋体;color:#555555'>或</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>short</span><span style='font-family:宋体;
color:#555555'>。所占字节和取值范围均与基本型相同。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>长整型：类型说明符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>long int</span><span
style='font-family:宋体;color:#555555'>或</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>long</span><span style='font-family:宋体;
color:#555555'>，在内存中占</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>4</span><span style='font-family:宋体;color:#555555'>个字节。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>4.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>无符号型：类型说明符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>unsigned</span><span
style='font-family:宋体;color:#555555'>。</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>无符号型又可与上述三种类型匹配而构成：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>无符号基本型：类型说明符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>unsigned int</span><span
style='font-family:宋体;color:#555555'>或</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>unsigned</span><span style='font-family:
宋体;color:#555555'>。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>无符号短整型：类型说明符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>unsigned
short</span><span style='font-family:宋体;color:#555555'>。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>无符号长整型：类型说明符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>unsigned
long</span><span style='font-family:宋体;color:#555555'>。</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>各种无符号类型量所占的内存空间字节数与相应的有符号类型量相同。但由于省去了符号位，故不能表示负数。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span lang=EN-US><img width=448 height=95 src="3.files/image005.jpg"></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>下表列出了</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>Turbo C</span><span style='font-family:宋体;color:#555555;background:white'>中各类整型量所分配的内存字节数及数的表示范围。</span></p>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td width=151 style='width:113.25pt;border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>类型说明符</span></p>
  </td>
  <td width=360 style='width:270.0pt;border:solid #999999 1.0pt;border-left:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>数的范围</span></p>
  </td>
  <td width=57 style='width:42.75pt;border:solid #999999 1.0pt;border-left:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>字节数</span></p>
  </td>
 </tr>
 <tr>
  <td width=151 style='width:113.25pt;border:solid #999999 1.0pt;border-top:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>int</span></p>
  </td>
  <td width=360 style='width:270.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>-32768~32767&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span><span style='font-family:宋体;color:#555555'>即</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>-2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>15</span></sup>~</span><span
  style='font-family:宋体;color:#555555'>（</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>15</span></sup>-1</span><span
  style='font-family:宋体;color:#555555'>）</span></p>
  </td>
  <td width=57 style='width:42.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2</span></p>
  </td>
 </tr>
 <tr>
  <td width=151 style='width:113.25pt;border:solid #999999 1.0pt;border-top:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>unsigned int</span></p>
  </td>
  <td width=360 style='width:270.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0~65535&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span><span style='font-family:宋体;color:#555555'>即</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0~</span><span
  style='font-family:宋体;color:#555555'>（</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>16</span></sup>-1</span><span
  style='font-family:宋体;color:#555555'>）</span></p>
  </td>
  <td width=57 style='width:42.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2</span></p>
  </td>
 </tr>
 <tr>
  <td width=151 style='width:113.25pt;border:solid #999999 1.0pt;border-top:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>short int</span></p>
  </td>
  <td width=360 style='width:270.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>-32768~32767&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span><span style='font-family:宋体;color:#555555'>即</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>-2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>15</span></sup>~</span><span
  style='font-family:宋体;color:#555555'>（</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>15</span></sup>-1</span><span
  style='font-family:宋体;color:#555555'>）</span></p>
  </td>
  <td width=57 style='width:42.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2</span></p>
  </td>
 </tr>
 <tr>
  <td width=151 style='width:113.25pt;border:solid #999999 1.0pt;border-top:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>unsigned short int</span></p>
  </td>
  <td width=360 style='width:270.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0~65535&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span><span style='font-family:宋体;color:#555555'>即</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0~</span><span
  style='font-family:宋体;color:#555555'>（</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>16</span></sup>-1</span><span
  style='font-family:宋体;color:#555555'>）</span></p>
  </td>
  <td width=57 style='width:42.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2</span></p>
  </td>
 </tr>
 <tr>
  <td width=151 style='width:113.25pt;border:solid #999999 1.0pt;border-top:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>long int</span></p>
  </td>
  <td width=360 style='width:270.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>-2147483648~2147483647</span><span
  style='font-family:宋体;color:#555555'>即</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>-2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>31</span></sup>~</span><span
  style='font-family:宋体;color:#555555'>（</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>31</span></sup>-1</span><span
  style='font-family:宋体;color:#555555'>）</span></p>
  </td>
  <td width=57 style='width:42.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>4</span></p>
  </td>
 </tr>
 <tr>
  <td width=151 style='width:113.25pt;border:solid #999999 1.0pt;border-top:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>unsigned long</span></p>
  </td>
  <td width=360 style='width:270.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0~4294967295&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  </span><span style='font-family:宋体;color:#555555'>即</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0~</span><span
  style='font-family:宋体;color:#555555'>（</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>32</span></sup>-1</span><span
  style='font-family:宋体;color:#555555'>）</span></p>
  </td>
  <td width=57 style='width:42.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>4</span></p>
  </td>
 </tr>
</table>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>&nbsp;</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>以</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>13</span><span style='font-family:宋体;color:#555555;background:white'>为例：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span lang=EN-US><img width=501 height=156 src="3.files/image006.jpg"></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span lang=EN-US><img width=500 height=119 src="3.files/image007.jpg"></span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>整型变量的定义</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>变量定义的一般形式为：类型说明符</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&nbsp; </span><span style='font-family:宋体;color:#555555;background:white'>变量名标识符，变量名标识符，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>...</span><span style='font-family:宋体;color:#555555;background:white'>；</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>&nbsp;&nbsp;&nbsp; int a,b,c; (a,b,c</span></span><span
style='font-family:宋体;color:#555555;background:white'>为整型变量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<span style='background:white'>&nbsp;&nbsp;&nbsp; long x,y; (x,y</span></span><span
style='font-family:宋体;color:#555555;background:white'>为长整型变量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<span style='background:white'>&nbsp; &nbsp; unsigned p,q; (p,q</span></span><span
style='font-family:宋体;color:#555555;background:white'>为无符号整型变量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:purple;border:none windowtext 1.0pt;
padding:0cm;background:white'>在书写变量定义时，应注意以下几点：</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>允许在一个类型说明符后，定义多个相同类型的变量。各变量名之间用逗号间隔。类型说明符与变量名之间至少用一个空格间隔。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>最后一个变量名之后必须以</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>“</span><span
style='font-family:宋体;color:#555555'>；</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>”</span><span style='font-family:宋体;
color:#555555'>号结尾。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-size:10.0pt;font-family:Wingdings;color:#555555'>§<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>变量定义必须放在变量使用之前。一般放在函数体的开头部分。</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.2</span><span style='font-family:宋体;color:#555555;background:white'>】整型变量的定义与使用。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>int a,b,c,d;</span><br>
<span style='background:white'>unsigned u;</span><br>
<span style='background:white'>a=12;b=-24;u=10;</span><br>
<span style='background:white'>c=a+u;d=b+u;</span><br>
<span style='background:white'>printf(“a+u=%d,b+u=%d\n”,c,d);</span><br>
<span style='background:white'>}</span><br>
<br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>整型数据的溢出</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.3</span><span style='font-family:宋体;color:#555555;background:white'>】整型数据的溢出。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>&nbsp; int a,b;</span><br>
<span style='background:white'>&nbsp; a=32767;</span><br>
<span style='background:white'>&nbsp; b=a+1;</span><br>
<span style='background:white'>&nbsp; printf(&quot;%d,%d\n&quot;,a,b);</span><br>
<span style='background:white'>&nbsp;}</span><br>
<br>
<span style='background:white'>32767:</span></span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td style='border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>-32768</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td style='border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.4</span><span style='font-family:宋体;color:#555555;background:white'>】</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main(){</span><br>
<span style='background:white'>&nbsp; long x,y;</span><br>
<span style='background:white'>&nbsp; int a,b,c,d;</span><br>
<span style='background:white'>&nbsp; x=5;</span><br>
<span style='background:white'>&nbsp; y=6;</span><br>
<span style='background:white'>&nbsp; a=7;</span><br>
<span style='background:white'>&nbsp; b=8;</span><br>
<span style='background:white'>&nbsp; c=x+a;</span><br>
<span style='background:white'>&nbsp; d=y+b;</span><br>
<span style='background:white'>&nbsp;
printf(&quot;c=x+a=%d,d=y+b=%d\n&quot;,c,d);</span><br>
<span style='background:white'>&nbsp;}</span><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>从程序中可以看到：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>x, y</span><span style='font-family:宋体;color:#555555;background:white'>是长整型变量，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a, b</span><span style='font-family:宋体;color:#555555;background:white'>是基本整型变量。它们之间允许进行运算，运算结果为长整型。但</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>c</span><span style='font-family:宋体;color:#555555;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>d</span><span style='font-family:宋体;color:#555555;background:white'>被定义为基本整型，因此最后结果为基本整型。本例说明，不同类型的量可以参与运算并相互赋值。其中的类型转换是由编译系统自动完成的。有关类型转换的规则将在以后介绍。</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.1</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>实型常量的表示方法</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>实型也称为浮点型。实型常量也称为实数或者浮点数。在Ｃ语言中，实数只采用十进制。它有二种形式：十进制小数形式，指数形式。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>十进制数形式：由数码</span></strong><strong><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>0~ 9</span></strong><strong><span style='font-family:宋体;
color:green;border:none windowtext 1.0pt;padding:0cm'>和小数点组成。</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0.0</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>25.0</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>5.789</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>0.13</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>5.0</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>300.</span><span style='font-family:宋体;color:#555555;background:white'>、</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>-267.8230</span><span style='font-family:宋体;color:#555555;background:
white'>等均为合法的实数。注意，必须有小数点。</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>指数形式：由十进制数，加阶码标志</span></strong><strong><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>“e”</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>或</span></strong><strong><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm'>“E”</span></strong><strong><span style='font-family:宋体;color:green;
border:none windowtext 1.0pt;padding:0cm'>以及阶码（只能为整数，可以带符号）组成。</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>其一般形式为：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a E n</span><span style='font-family:宋体;color:#555555;background:white'>（</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a</span><span style='font-family:宋体;color:#555555;background:white'>为十进制数，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>n</span><span style='font-family:宋体;color:#555555;background:white'>为十进制整数）</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>其值为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'> a*10<sup><span style='border:none windowtext 1.0pt;padding:0cm'>n</span></sup></span><span
style='font-family:宋体;color:#555555;background:white'>。如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>2.1E5 (</span></span><span style='font-family:
宋体;color:#555555;background:white'>等于</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>2.1*10<sup><span
style='border:none windowtext 1.0pt;padding:0cm'>5</span></sup>)</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>3.7E-2 (</span></span><span style='font-family:
宋体;color:#555555;background:white'>等于</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>3.7*10<sup><span
style='border:none windowtext 1.0pt;padding:0cm'>-2</span></sup>)</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>0.5E7 (</span></span><span style='font-family:
宋体;color:#555555;background:white'>等于</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>0.5*10<sup><span
style='border:none windowtext 1.0pt;padding:0cm'>7</span></sup>)</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>-2.8E-2 (</span></span><span style='font-family:
宋体;color:#555555;background:white'>等于</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>-2.8*10<sup><span
style='border:none windowtext 1.0pt;padding:0cm'>-2</span></sup>)</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>以下不是合法的实数：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>345 (</span></span><span style='font-family:
宋体;color:#555555;background:white'>无小数点</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>)</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>E7 (</span></span><span style='font-family:宋体;
color:#555555;background:white'>阶码标志</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>E</span><span
style='font-family:宋体;color:#555555;background:white'>之前无数字</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<span style='background:white'>-5 (</span></span><span style='font-family:宋体;
color:#555555;background:white'>无阶码标志</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>)</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>53.-E3 (</span></span><span style='font-family:
宋体;color:#555555;background:white'>负号位置不对</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>)</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>2.7E&nbsp; (</span></span><span
style='font-family:宋体;color:#555555;background:white'>无阶码</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>标准Ｃ允许浮点数使用后缀。后缀为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>“f”</span><span style='font-family:宋体;color:#555555;background:white'>或</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>“F”</span><span style='font-family:宋体;color:#555555;background:white'>即表示该数为浮点数。如</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>356f</span><span style='font-family:宋体;color:#555555;background:white'>和</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>356.</span><span style='font-family:宋体;color:#555555;background:white'>是等价的。【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.5</span><span style='font-family:宋体;color:#555555;background:white'>】说明了这种情况。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main(){</span><br>
<span style='background:white'>&nbsp; printf(&quot;%f\n &quot;,356.);</span><br>
<span style='background:white'>&nbsp; printf(&quot;%f\n &quot;,356);</span><br>
<span style='background:white'>&nbsp; printf(&quot;%f\n &quot;,356f);</span><br>
<span style='background:white'>}</span><br>
<br>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.2</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>实型变量</span></h3>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>实型数据在内存中的存放形式</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>实型数据一般占</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>4</span><span style='font-family:宋体;color:#555555;background:white'>个字节（</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>32</span><span style='font-family:宋体;color:#555555;background:white'>位）内存空间。按指数形式存储。实数</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.14159</span><span style='font-family:宋体;color:#555555;background:white'>在内存中的存放形式如下：</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td width=22 style='width:16.5pt;border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>+</span></p>
  </td>
  <td width=249 style='width:186.75pt;border:solid #999999 1.0pt;border-left:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>.314159</span></p>
  </td>
  <td width=84 style='width:63.0pt;border:solid #999999 1.0pt;border-left:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style='font-family:宋体;color:#555555;background:white'>数符</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span
style='font-family:宋体;color:#555555;background:white'>小数部分</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span><span style='font-family:宋体;color:#555555;background:white'>指数</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>小数部分占的位（</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>bit</span><span
style='font-family:宋体;color:#555555'>）数愈多，数的有效数字愈多，精度愈高。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>指数部分占的位数愈多，则能表示的数值范围愈大。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>实型变量的分类</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:purple;border:none windowtext 1.0pt;
padding:0cm;background:white'>实型变量分为：单精度（</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:purple;border:none windowtext 1.0pt;
padding:0cm;background:white'>float</span><span style='font-family:宋体;
color:purple;border:none windowtext 1.0pt;padding:0cm;background:white'>型）、双精度（</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:purple;border:none windowtext 1.0pt;
padding:0cm;background:white'>double</span><span style='font-family:宋体;
color:purple;border:none windowtext 1.0pt;padding:0cm;background:white'>型）和长双精度（</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:purple;border:none windowtext 1.0pt;
padding:0cm;background:white'>long double</span><span style='font-family:宋体;
color:purple;border:none windowtext 1.0pt;padding:0cm;background:white'>型）三类。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>在</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>Turbo C</span><span style='font-family:宋体;color:#555555;background:white'>中单精度型占</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>4</span><span style='font-family:宋体;color:#555555;background:white'>个字节（</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>32</span><span style='font-family:宋体;color:#555555;background:white'>位）内存空间，其数值范围为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.4E-38</span><span style='font-family:宋体;color:#555555;background:white'>～</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.4E+38</span><span style='font-family:宋体;color:#555555;background:white'>，只能提供七位有效数字。双精度型占</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>8 </span><span style='font-family:宋体;color:#555555;background:white'>个字节（</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>64</span><span style='font-family:宋体;color:#555555;background:white'>位）内存空间，其数值范围为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>1.7E-308</span><span style='font-family:宋体;color:#555555;background:
white'>～</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>1.7E+308</span><span style='font-family:宋体;
color:#555555;background:white'>，可提供</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>16</span><span
style='font-family:宋体;color:#555555;background:white'>位有效数字。</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>类型说明符</span></p>
  </td>
  <td width=120 style='width:90.0pt;border:solid #999999 1.0pt;border-left:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>比特数（字节数）</span></p>
  </td>
  <td width=78 style='width:58.5pt;border:solid #999999 1.0pt;border-left:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>有效数字</span></p>
  </td>
  <td width=157 style='width:117.75pt;border:solid #999999 1.0pt;border-left:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>数的范围</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>float</span></p>
  </td>
  <td width=120 style='width:90.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>32</span><span
  style='font-family:宋体;color:#555555'>（</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>4</span><span
  style='font-family:宋体;color:#555555'>）</span></p>
  </td>
  <td width=78 style='width:58.5pt;border-top:none;border-left:none;border-bottom:
  solid #999999 1.0pt;border-right:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>6~7</span></p>
  </td>
  <td width=157 style='width:117.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>10<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>-37</span></sup>~10<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>38</span></sup>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>double</span></p>
  </td>
  <td width=120 style='width:90.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>64(8)</span></p>
  </td>
  <td width=78 style='width:58.5pt;border-top:none;border-left:none;border-bottom:
  solid #999999 1.0pt;border-right:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>15~16</span></p>
  </td>
  <td width=157 style='width:117.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>10<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>-307</span></sup>~10<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>308</span></sup></span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>long double</span></p>
  </td>
  <td width=120 style='width:90.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>128(16)</span></p>
  </td>
  <td width=78 style='width:58.5pt;border-top:none;border-left:none;border-bottom:
  solid #999999 1.0pt;border-right:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>18~19</span></p>
  </td>
  <td width=157 style='width:117.75pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>10<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>-4931</span></sup>~10<sup><span
  style='border:none windowtext 1.0pt;padding:0cm'>4932</span></sup></span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>实型变量定义的格式和书写规则与整型相同。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>&nbsp;&nbsp;&nbsp; </span></span><span
style='font-family:宋体;color:#555555;background:white'>　</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>float
x,y; (x,y</span><span style='font-family:宋体;color:#555555;background:white'>为单精度实型量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<span style='background:white'>&nbsp; &nbsp; &nbsp; &nbsp; double a,b,c; (a,b,c</span></span><span
style='font-family:宋体;color:#555555;background:white'>为双精度实型量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>)</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm'>实型数据的舍入误差</span></strong></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>由于实型变量是由有限的存储单元组成的，因此能提供的有效数字总是有限的。如下例。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.6</span><span style='font-family:宋体;color:#555555;background:white'>】实型数据的舍入误差。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{float a,b;</span><br>
<span style='background:white'>&nbsp;a=123456.789e5;</span><br>
<span style='background:white'>&nbsp;b=a+20</span><br>
<span style='background:white'>printf(&quot;%f\n&quot;,a);</span><br>
<span style='background:white'>printf(&quot;%f\n&quot;,b);</span><br>
<span style='background:white'>}</span><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>注意：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>1.0/3*3</span><span style='font-family:宋体;color:#555555;background:white'>的结果并不等于</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>1</span><span style='font-family:宋体;color:#555555;background:white'>。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.7</span><span style='font-family:宋体;color:#555555;background:white'>】</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>&nbsp;&nbsp; float a;</span><br>
<span style='background:white'>&nbsp;&nbsp; double b;</span><br>
<span style='background:white'>&nbsp;&nbsp; a=33333.33333;</span><br>
<span style='background:white'>&nbsp;&nbsp; b=33333.33333333333333;</span><br>
<span style='background:white'>&nbsp;&nbsp; printf(&quot;%f\n%f\n&quot;,a,b);</span><br>
<span style='background:white'>&nbsp;}</span><br>
<br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>从本例可以看出，由于</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>a </span><span
style='font-family:宋体;color:#555555'>是单精度浮点型，有效位数只有七位。而整数已占五位，故小数二位后之后均为无效数字。</span></p>

<p class=MsoNormal align=left style='margin-left:0cm;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>b </span><span style='font-family:宋体;color:#555555'>是双精度型，有效位为十六位。但</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>Turbo C </span><span
style='font-family:宋体;color:#555555'>规定小数后最多保留六位，其余部分四舍五入。</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.3</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>实型常数的类型</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>实型常数不分单、双精度，都按双精度</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>double</span><span style='font-family:宋体;color:#555555;background:white'>型处理。</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>字符型数据包括字符常量和字符变量。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.1</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>字符常量</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>字符常量是用单引号括起来的一个字符。例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>'a'</span></span><span style='font-family:宋体;
color:#555555;background:white'>、</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>'b'</span><span
style='font-family:宋体;color:#555555;background:white'>、</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>'='</span><span
style='font-family:宋体;color:#555555;background:white'>、</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>'+'</span><span
style='font-family:宋体;color:#555555;background:white'>、</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>'?'</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>都是合法字符常量。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'>在Ｃ语言中，字符常量有以下特点：</span></strong><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>字符常量只能用单引号括起来，不能用双引号或其它括号。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>字符常量只能是单个字符，不能是字符串。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>字符可以是字符集中任意字符。但数字被定义为字符型之后就不能参与数值运算。如</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>'5'</span><span
style='font-family:宋体;color:#555555'>和</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'>5 </span><span style='font-family:宋体;
color:#555555'>是不同的。</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'>'5'</span><span style='font-family:宋体;color:#555555'>是字符常量，不能参与运算。</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.2</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>转义字符</span></h3>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>&nbsp;&nbsp;&nbsp; </span><span
style='font-family:宋体;color:#555555;background:white'>转义字符是一种特殊的字符常量。转义字符以反斜线</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&quot;\&quot;</span><span style='font-family:宋体;color:#555555;
background:white'>开头，后跟一个或几个字符。转义字符具有特定的含义，不同于字符原有的意义，故称</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>“</span><span style='font-family:宋体;color:#555555;background:white'>转义</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>”</span><span style='font-family:宋体;color:#555555;background:white'>字符。例如，在前面各例题</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>printf</span><span style='font-family:宋体;color:#555555;background:white'>函数的格式串中用到的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>“\n”</span><span style='font-family:宋体;color:#555555;background:white'>就是一个转义字符，其意义是</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>“</span><span style='font-family:宋体;color:#555555;background:white'>回车换行</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>”</span><span style='font-family:宋体;color:#555555;background:white'>。转义字符主要用来表示那些用一般字符不便于表示的控制代码。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><strong><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'>常用的转义字符及其含义</span></strong></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>转义字符</span></p>
  </td>
  <td width=276 style='width:207.0pt;border:solid #999999 1.0pt;border-left:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>转义字符的意义</span></p>
  </td>
  <td width=144 style='width:108.0pt;border:solid #999999 1.0pt;border-left:
  none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>ASCII</span><span
  style='font-family:宋体;color:#555555'>代码</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \n</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>回车换行</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>10</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \t</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>横向跳到下一制表位置</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>9</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \b</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>退格</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>8</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \r</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>回车</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>13</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \f</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>走纸换页</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>12</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \\</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>反斜线符</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
  color:#555555'>&quot;\&quot;</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>92</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \'</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>单引号符</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>39</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>\”</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>双引号符</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>34</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \a</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span style='font-family:宋体;
  color:#555555'>鸣铃</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>7</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \ddd</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span><span
  style='font-family:宋体;color:#555555'>～</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>3</span><span
  style='font-family:宋体;color:#555555'>位八进制数所代表的字符</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>
  </td>
 </tr>
 <tr>
  <td width=91 style='width:68.25pt;border:solid #999999 1.0pt;border-top:none;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
  \xhh</span></p>
  </td>
  <td width=276 style='width:207.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span><span
  style='font-family:宋体;color:#555555'>～</span><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>2</span><span
  style='font-family:宋体;color:#555555'>位十六进制数所代表的字符</span></p>
  </td>
  <td width=144 style='width:108.0pt;border-top:none;border-left:none;
  border-bottom:solid #999999 1.0pt;border-right:solid #999999 1.0pt;
  padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>广义地讲，Ｃ语言字符集中的任何一个字符均可用转义字符来表示。表中的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>\ddd</span><span style='font-family:宋体;color:#555555;background:white'>和</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>\xhh</span><span style='font-family:宋体;color:#555555;background:white'>正是为此而提出的。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ddd</span><span style='font-family:宋体;color:#555555;background:white'>和</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>hh</span><span style='font-family:宋体;color:#555555;background:white'>分别为八进制和十六进制的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ASCII</span><span style='font-family:宋体;color:#555555;background:white'>代码。如</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>\101</span><span style='font-family:宋体;color:#555555;background:white'>表示字母</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&quot;A&quot; </span><span style='font-family:宋体;color:#555555;
background:white'>，</span><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>\102</span><span style='font-family:宋体;
color:#555555;background:white'>表示字母</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>&quot;B&quot;</span><span
style='font-family:宋体;color:#555555;background:white'>，</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'>\134</span><span
style='font-family:宋体;color:#555555;background:white'>表示反斜线，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>\XOA</span><span style='font-family:宋体;color:#555555;background:white'>表示换行等。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.8</span><span style='font-family:宋体;color:#555555;background:white'>】转义字符的使用。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>&nbsp; int a,b,c;</span><br>
<span style='background:white'>&nbsp; a=5; b=6; c=7;</span><br>
<span style='background:white'>&nbsp; printf(“&nbsp; ab&nbsp; c\tde\rf\n”);</span><br>
<span style='background:white'>printf(“hijk\tL\bM\n”);</span><br>
<span style='background:white'>}</span><br>
<br>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.3</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>字符变量</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>字符变量用来存储字符常量，即单个字符。字符变量的类型说明符是</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>char</span><span style='font-family:宋体;color:#555555;background:white'>。字符变量类型定义的格式和书写规则都与整型变量相同。例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>&nbsp;char a,b;</span><br>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.4</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>字符数据在内存中的存储形式及使用方法</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'>每个字符变量被分配一个字节的内存空间，因此只能存放一个字符。</span><span
style='font-family:宋体;color:#555555;background:white'>字符值是以</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ASCII</span><span style='font-family:宋体;color:#555555;background:white'>码的形式存放在变量的内存单元之中的。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>如</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>x</span><span style='font-family:宋体;color:#555555;background:white'>的十进制</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ASCII</span><span style='font-family:宋体;color:#555555;background:white'>码是</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>120</span><span style='font-family:宋体;color:#555555;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>y</span><span style='font-family:宋体;color:#555555;background:white'>的十进制</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ASCII</span><span style='font-family:宋体;color:#555555;background:white'>码是</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>121</span><span style='font-family:宋体;color:#555555;background:white'>。对字符变量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a,b</span><span style='font-family:宋体;color:#555555;background:white'>赋予</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>'x'</span><span style='font-family:宋体;color:#555555;background:white'>和</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>'y'</span><span style='font-family:宋体;color:#555555;background:white'>值：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>a='x';</span><br>
<span style='background:white'>b='y';</span><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>实际上是在</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a,b</span><span style='font-family:宋体;color:#555555;background:white'>两个单元内存放</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>120</span><span style='font-family:宋体;color:#555555;background:white'>和</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>121</span><span style='font-family:宋体;color:#555555;background:white'>的二进制代码：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>a</span></span><span style='font-family:宋体;
color:#555555;background:white'>：</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td style='border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>b</span><span style='font-family:宋体;color:#555555;
background:white'>：</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td style='border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>0</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>1</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>&nbsp;</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>所以也可以把它们看成是整型量。Ｃ语言允许对整型变量赋以字符值，也允许对字符变量赋以整型值。在输出时，允许把字符变量按整型量输出，也允许把整型量按字符量输出。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>整型量为二字节量，字符量为单字节量，当整型量按字符型量处理时，只有低八位字节参与处理。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.9</span><span style='font-family:宋体;color:#555555;background:white'>】向字符变量赋以整数。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>&nbsp; char a,b;</span><br>
<span style='background:white'>&nbsp; a=120;</span><br>
<span style='background:white'>&nbsp; b=121;</span><br>
<span style='background:white'>&nbsp; printf(&quot;%c,%c\n&quot;,a,b);</span><br>
<span style='background:white'>printf(&quot;%d,%d\n&quot;,a,b);</span><br>
<span style='background:white'>}</span><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>本程序中定义</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a</span><span style='font-family:宋体;color:#555555;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>b</span><span style='font-family:宋体;color:#555555;background:white'>为字符型，但在赋值语句中赋以整型值。从结果看，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a</span><span style='font-family:宋体;color:#555555;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>b</span><span style='font-family:宋体;color:#555555;background:white'>值的输出形式取决于</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>printf</span><span style='font-family:宋体;color:#555555;background:white'>函数格式串中的格式符，当格式符为</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&quot;c&quot;</span><span style='font-family:宋体;color:#555555;
background:white'>时，对应输出的变量值为字符，当格式符为</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555;background:white'>&quot;d&quot;</span><span
style='font-family:宋体;color:#555555;background:white'>时，对应输出的变量值为整数。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.10</span><span style='font-family:宋体;color:#555555;background:white'>】</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>&nbsp; char a,b;</span><br>
<span style='background:white'>&nbsp; a='a';</span><br>
<span style='background:white'>&nbsp; b='b';</span><br>
<span style='background:white'>&nbsp; a=a-32;</span><br>
<span style='background:white'>&nbsp; b=b-32;</span><br>
<span style='background:white'>&nbsp;
printf(&quot;%c,%c\n%d,%d\n&quot;,a,b,a,b);</span><br>
<span style='background:white'>&nbsp;}</span><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>本例中，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>a</span><span style='font-family:宋体;color:#555555;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>b</span><span style='font-family:宋体;color:#555555;background:white'>被说明为字符变量并赋予字符值，Ｃ语言允许字符变量参与数值运算，即用字符的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ASCII </span><span style='font-family:宋体;color:#555555;background:white'>码参与运算。由于大小写字母的</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>ASCII </span><span style='font-family:宋体;color:#555555;background:white'>码相差</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>32</span><span style='font-family:宋体;color:#555555;background:white'>，因此运算后把小写字母换成大写字母。然后分别以整型和字符型输出。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<h3 style='margin:0cm;margin-bottom:.0001pt;line-height:30.0pt;background:white;
vertical-align:middle'><span lang=EN-US style='font-size:12.0pt;font-family:
"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;padding:0cm'>3.1.5</span><span
style='font-size:12.0pt;font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm'>字符串常量</span></h3>

<p class=MsoNormal><span style='font-family:宋体;color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'>字符串常量是由一对双引号括起的字符序列。例如：</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'> &quot;CHINA&quot; </span><span style='font-family:
宋体;color:green;border:none windowtext 1.0pt;padding:0cm;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'> “C program” </span><span style='font-family:
宋体;color:green;border:none windowtext 1.0pt;padding:0cm;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:green;border:none windowtext 1.0pt;
padding:0cm;background:white'> &quot;$12.5&quot; </span><span style='font-family:
宋体;color:green;border:none windowtext 1.0pt;padding:0cm;background:white'>等都是合法的字符串常量。</span><span
style='font-family:宋体;color:#555555;background:white'>字符串常量和字符常量是不同的量。它们之间主要有以下区别：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>1.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>字符常量由单引号括起来，字符串常量由双引号括起来。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>2.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>字符常量只能是单个字符，字符串常量则可以含一个或多个字符。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>3.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>可以把一个字符常量赋予一个字符变量，但不能把一个字符串常量赋予一个字符变量。在Ｃ语言中没有相应的字符串变量。这是与</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>BASIC </span><span
style='font-family:宋体;color:#555555'>语言不同的。但是可以用一个字符数组来存放一个字符串常量。在数组一章内予以介绍。</span></p>

<p class=MsoNormal align=left style='margin-left:22.5pt;text-align:left;
text-indent:-18.0pt;line-height:16.5pt;background:white'><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>4.<span
style='font:7.0pt "Times New Roman"'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><span style='font-family:宋体;color:#555555'>字符常量占一个字节的内存空间。字符串常量占的内存字节数等于字符串中字节数加</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>1</span><span
style='font-family:宋体;color:#555555'>。增加的一个字节中存放字符</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>&quot;\0&quot; (ASCII</span><span
style='font-family:宋体;color:#555555'>码为</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'>0)</span><span
style='font-family:宋体;color:#555555'>。这是字符串结束的标志。</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
</span><span style='font-family:宋体;color:#555555;background:white'>字符串</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'> &quot;C program&quot; </span><span style='font-family:宋体;color:#555555;
background:white'>在内存中所占的字节为：</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td style='border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>C</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>p</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>r</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>o</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>g</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>r</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>a</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>m</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>\0</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>字符常量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>'a'</span><span style='font-family:宋体;color:#555555;background:white'>和字符串常量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>&quot;a&quot;</span><span style='font-family:宋体;color:#555555;
background:white'>虽然都只有一个字符，但在内存中的情况是不同的。</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>'a'</span></span><span style='font-family:宋体;
color:#555555;background:white'>在内存中占一个字节，可表示为：</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td style='border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>a</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal style='line-height:16.5pt;background:white'><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'>&nbsp;</span></p>

<p class=MsoNormal><span lang=EN-US style='font-family:"Tahoma","sans-serif";
color:#555555;background:white'>&quot;a&quot;</span><span style='font-family:
宋体;color:#555555;background:white'>在内存中占二个字节，可表示为：</span></p>

<div align=center>

<table class=MsoNormalTable border=0 cellspacing=0 cellpadding=0
 style='background:white;border-collapse:collapse'>
 <tr>
  <td style='border:solid #999999 1.0pt;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>a</span></p>
  </td>
  <td style='border:solid #999999 1.0pt;border-left:none;padding:3.75pt 3.75pt 3.75pt 3.75pt'>
  <p class=MsoNormal style='line-height:16.5pt'><span lang=EN-US
  style='font-family:"Tahoma","sans-serif";color:#555555'>\0</span></p>
  </td>
 </tr>
</table>

</div>

<p class=MsoNormal><span style='font-family:宋体;color:#555555;background:white'>在程序中常常需要对变量赋初值，以便使用变量。语言程序中可有多种方法为变量提供初值。本小节先介绍在作变量定义的同时给变量赋以初值的方法。这种方法称为初始化。在变量定义中赋初值的一般形式为：类型说明符</span><span
style='font-family:"Tahoma","sans-serif";color:#555555;background:white'> </span><span
style='font-family:宋体;color:#555555;background:white'>变量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>1= </span><span style='font-family:宋体;color:#555555;background:white'>值</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>1</span><span style='font-family:宋体;color:#555555;background:white'>，变量</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>2= </span><span style='font-family:宋体;color:#555555;background:white'>值</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>2</span><span style='font-family:宋体;color:#555555;background:white'>，</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>……</span><span style='font-family:宋体;color:#555555;background:white'>；</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>例如：</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>int a=3</span></span><span style='font-family:
宋体;color:#555555;background:white'>；</span><span lang=EN-US style='font-family:
"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>int b,c=5;</span><br>
<span style='background:white'>float x=3.2,y=3f,z=0.75;</span><br>
<span style='background:white'>char ch1='K',ch2='P';</span><br>
<br>
</span><span style='font-family:宋体;color:red;border:none windowtext 1.0pt;
padding:0cm;background:white'>应注意，在定义中不允许连续赋值，如</span><span lang=EN-US
style='font-family:"Tahoma","sans-serif";color:red;border:none windowtext 1.0pt;
padding:0cm;background:white'>a=b=c=5</span><span style='font-family:宋体;
color:red;border:none windowtext 1.0pt;padding:0cm;background:white'>是不合法的。</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<br>
</span><span style='font-family:宋体;color:#555555;background:white'>【例</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555;background:
white'>3.11</span><span style='font-family:宋体;color:#555555;background:white'>】</span><span
lang=EN-US style='font-family:"Tahoma","sans-serif";color:#555555'><br>
<span style='background:white'>main()</span><br>
<span style='background:white'>{</span><br>
<span style='background:white'>&nbsp;&nbsp; int a=3,b,c=5;</span><br>
<span style='background:white'>&nbsp;&nbsp; b=a+c;</span><br>
<span style='background:white'>&nbsp;&nbsp;
printf(&quot;a=%d,b=%d,c=%d\n&quot;,a,b,c);</span><br>
<span style='background:white'>}</span></span></p>

</div>

</body>

</html>
